<%@ page import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>课程列表</title>
<script LANGUAGE="JavaScript" type="text/javascript">
	function add(){
		window.open ("course/addCourse.jsp", "newwindow", "height=300, width=470, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no")
		}

function load() {
		var str=document.getElementsByName('cids');
		var ids =new Array();
		var j=0;
		for(i=0;i<str.length;i++){
			if(str[i].checked == true){
					ids[j]=str[i].value;
					j++;
			}
		}
		if(ids.length==1){
		  	 window.location.href='loadCourse?cids='+ids[0];
		}else{
			alert("请先选择一条记录！");
		  	return false;
		}
	}
function del_confirm()
	{	
		var str=document.getElementsByName('cids');
		var ids =new Array();
		var j=0;
		for(i=0;i<str.length;i++){
			if(str[i].checked == true){
					ids[j]=str[i].value;
					j++;
			}
		}
		if(ids.length==0){
			alert("请先选择要删除的记录!");
			return false;
			}
		var r=confirm("确定删除吗？");
		if (r==true)
 		 {
 		 	return true;
 		 }
		else
 		 {
  			return false;
  		}
	}
</script>
</head>

<body>
	<form method="post" action="deleteCourse">
	<table>
    	<tr align="center">
        	<td width="20">&nbsp;</td><td width="100">编号</td><td width="200">课程名称</td><td width="200">课程图片</td>
        </tr>
		<c:forEach items="${courseL}" var="course">
        <tr align="center">
        	<td width="20">
            	<input type="checkbox" value="${course.cid }" name="cids" />
            </td><td width="100">
            	${course.cid }
            </td><td width="200">${course.cname }</td><td width="200">${course.cpic }</td>
        </tr>
         </c:forEach>
        <tr>
        	<td colspan="4" align="center">
            	<input type="button" value="上一页" />共1页，当前第1页<input type="button" value="下一页" /><br/>
            	<input type="button" value="添加" onclick="add()" /><input type="button" value="查看" onclick="load()"/><input type="submit" value="删除" onclick="del_confirm()" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
